<template>
  <div class="editAnswer">
    <div >
      <editor-bar v-model="info" @change="getEditor"></editor-bar>
      <br>
      <a-button type="primary" @click="submit">提交</a-button>
    </div>
  </div>
</template>

<script>
import EditorBar from '@/components/Editor/WangEditor'
import { editInfoSubmit, geteditInfo } from '@/api/user/knowledge'

export default {
  name: 'EditAnswer',
  components: {
    EditorBar
  },
  data () {
    return {
      idd: '',
      title_id: '',
      info: ''
    }
  },

  computed: {

  },
  created () {
    this.idd = this.$route.query.id
    this.title_id = this.$route.query.title_id
    // console.log('idd', this.idd)
    // console.log('tidd', this.title_id)
    this.geteditInfo()
  },
  mounted () {

  },
  methods: {
    geteditInfo () {
      geteditInfo({
        title_id: this.idd
      }).then(res => {
        // console.log(res)
        this.info = res.result.a_data
      }).catch(err => {
        console.log(err)
      })
    },
    // 提交
    submit () {
      editInfoSubmit({
        id: this.idd,
        title_id: this.title_id,
        a: this.info
      }).then(res => {
        // console.log(res)
        this.$message.info('提交成功!')
        this.$router.push({
        // name: 'passGoods',
          path: `/repository/answer-detil`,
          query: {
            id: this.title_id

          }
        })
      }).catch(err => {
        console.log(err)
        this.$message.info('提交失败!')
      })
    },
    getEditor (value) {
      // console.log(value)
      this.info = value
    }
  }
}
</script>

<style lang='less' scoped>

</style>
